import { types, Instance } from "mobx-state-tree";
import { BooksModel } from "./Books";
import { CartModel } from "./Cart";

export interface IRootStoreModel extends Instance<typeof RootStore> {}
export type RootStoreType = typeof RootStore.Type;

export const RootStore = types.model("RootStore", {
  bookStore: types.optional(BooksModel, {
    books: {},
  }),
  cartStore: types.optional(CartModel, {
    entries: [],
  }),
});

export const getDetaultStore = () => RootStore.create({});
